package com.five.wisdomEat.controller;

import cn.hutool.core.date.DateTime;
import com.five.wisdomEat.entity.Application;
import com.five.wisdomEat.entity.ResponseMessage;
import com.five.wisdomEat.service.ApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/application")
public class ApplicationController {
    @Autowired
    private ApplicationService service;
    @GetMapping("/getApplicationList")
    public ResponseMessage selectApplicationList(){
        return service.selectApplicationList();
    }

    @PostMapping("/insertApplication")
    public ResponseMessage insertApplication(String aBNumber){
        Application application = new Application();
        application.setABNumber(aBNumber);
        application.setATime(new DateTime());
        return service.insertApplication(application);
    }

    @PostMapping("/applyApplication")
    public ResponseMessage applyApplication(Integer id,String bNumber){
        Application application = new Application();
        application.setId(id);
        return service.applyApplication(application,bNumber);
    }

    @PostMapping("/refuseApplication")
    public ResponseMessage refuseApplication(Integer id){
        Application application = new Application();
        application.setId(id);
        return service.refuseApplication(application);
    }

    @GetMapping("/selectApplicationCount")
    public Integer selectApplicationCount(){
        return service.selectApplicationCount();
    }
}
